<template>
  <div>
    <titleTop :titleTxet="titleTxet"></titleTop>
    <div class="w1 t_center font_32 c_44 m_t40 m_d40">
      <span>机构认证</span>
    </div>
    <div class="w1 flex f_align f_content m_d40">
      <div class="designation font_28 c_44">机构名称</div>
      <div class="input_box font_28 c_28">
        <input
          type="text"
          v-model="true_name"
        >
      </div>
    </div>
    <div class="w1 flex f_align f_content m_d40">
      <div class="designation font_28 c_44">信用代码</div>
      <div class="input_box font_28 c_28">
        <input
          type="number"
          v-model="id_no"
        >
      </div>
    </div>
    <div class="w1 flex f_align f_content m_d40">
      <div class="designation font_28 c_44">注册地址</div>
      <div class="input_box font_28 c_28">
        <input
          type="text"
          v-model="location"
        >
      </div>
    </div>
    <div class="w1 flex f_align f_content m_d40">
      <div class="designation font_28 c_44">联系人</div>
      <div class="input_box font_28 c_28">
        <input
          type="text"
          v-model="linkman"
        >
      </div>
    </div>
    <div class="w1 flex f_align f_content m_d40">
      <div class="designation font_28 c_44">电话</div>
      <div class="input_box font_28 c_28">
        <input
          type="number"
          v-model="mobile"
        >
      </div>
    </div>
    <div class="papers_box flex f_align f_around">
      <van-uploader :after-read="onRead4">
        <img :src="resvers2?resvers2:require('../../../assets/img/realCompany.png')" alt="">
      </van-uploader>
    </div>
    <div class="container flex f_align ckeck_box f_content">
      <input
        @click="istrue2()"
        type="checkbox"
        :checked="checked"
      >
      <div class="m_l20">
        <span>认证协议说明</span>
      </div>
    </div>
    <div class="sub-btn t_center font_36 c_ff">
      <span @click="auths2()">提交</span>
    </div>
  </div>
</template>
<script>
import titleTop from "../../com/title";
import {Dialog} from 'vant';
import * as common from "../../../api/common.js";
export default {
  components: { titleTop },
  data() {
    return {
      titleTxet: {
        titleName: "机构认证",
        IsBool: true,
        IsShare: false
      },
      phone: "",
      code: "",
      true_name: "", //姓名
      id_no: "",
      location: "",
      linkman: "",
      mobile: "",
      checked: true,
      resvers2:''
    };
  },
  mounted(){
    mui.back = function() {
      window.history.go(-1);
    }
  },
  methods: {
    istrue2(){
      this.checked = !this.checked;
    },
    onRead4(file){
      this.resvers2 = file.content;
    },
    auths2(){
      if (this.checked){
        if (this.true_name.length==0||this.id_no.length==0||this.location.length==0||this.mobile.length==0||this.linkman.length==0||this.resvers2.length==0){
          Dialog.alert({
            message: '请完善信息'
          });
        } else{
          let parms = {
            type:4,
            true_name:this.true_name,
            id_no:this.id_no,
            location:this.location,
            mobile:this.mobile,
            linkman:this.linkman,
            business_pic:this.resvers2,
            user_id:this.$store.state.user_id
          };
          common.auth(parms).then(res=>{
            console.log(res);
            if (res.status==200) {
              Dialog.alert({
                message: '上传成功，请耐心等待'
              }).then(()=>{
                history.go(-1);
              });
            }
          })
        }

      } else{
        Dialog.alert({
          message: '亲，同意协议后才可以提交哦！'
        });
      }
    }
  }
};
</script>
<style scoped>
.designation {
  width: 150px;
}
.input_box input {
  width: 338px;
  height: 54px;
  line-height: 54px;
  padding: 0 15px;
  box-sizing: border-box;
  border: 1px solid #cccccc;
}
.papers_box img {
  width: 220px;
  height: 220px;
}
.ckeck_box {
  margin-top: 140px;
  margin-bottom: 66px;
}
.sub-btn {
  width: 400px;
  height: 80px;
  line-height: 80px;
  margin: 0 auto;
  background: #884ca4;
  border-radius: 10px;
  margin-bottom: 50px;
}
.sub-btn span{
  color: #fff;
}
</style>
